package desenhando;

import java.awt.Color;
import java.awt.Graphics;

import dados.Ponto;

public class Operacoes {
	
	public static void drawPoint(Ponto p, Graphics g){
		g.setColor(Color.BLACK);
		int x = (int) p.getX();
		int y = (int) p.getY();
		int size = 5;
		
		if(p.isSelecionado()){
			x -= 2;
			y -= 2;
			g.setColor(Color.BLUE);
			size = 10;
		}
		g.fillOval(x, y, size, size);
	}
	
	public static void drawLine(Ponto a, Ponto b, Graphics g) {
		// +3 -> Adjust position of the point so its center is over the edge of the line.
		int x1 = (int) a.getX() + 3;
		int y1 = (int) a.getY() + 3;

		int x2 = (int) b.getX() + 3;
		int y2 = (int) b.getY() + 3;
		g.setColor(Color.BLACK);
		g.drawLine(x1, y1, x2, y2);
	}

	public static void drawLine(Ponto a, Ponto b, Graphics g, Color color) {
		// +3 -> Adjust position of the point so its center is over the edge of the line.
		int x1 = (int) a.getX() + 3;
		int y1 = (int) a.getY() + 3;

		int x2 = (int) b.getX() + 3;
		int y2 = (int) b.getY() + 3;
		g.setColor(color);
		g.drawLine(x1, y1, x2, y2);
	}
}
